var packageNameMap = require("./packageNameMap");
var appNameMap = require("./appNameMap");
var timeHelper = require("./time");
module.exports = {
  getPackageName(appName) {
    return packageNameMap[appName];
  },
  goAutojs() {
    return this.launchApp("auto");
  },
  launchPackage(appName) {
    var packageName = this.getPackageName(appName);
    var result = app.launchPackage(packageName);
    if (!result) {
      console.log(`launchPackage ${appName} 失败了!!!`);
    }
    return result;
  },
  launchApp(appName) {
    var appName$ = appNameMap[appName] || appName;
    var result = app.launchApp(appName$);
    if (!result) {
      console.log(`launchApp ${appName} 失败了!!!`);
      return this.launchPackage(appName);
    }
    return result;
  },
  goAutojsThenOpen(appName, start, end) {
    start = start || 2;
    end = end || 4;
    if (!this.goAutojs()) {
      return false;
    }
    timeHelper.sleep(2, 4);
    return this.launchApp(appName);
  },
};
